	
	<div id="page-content">
			<div class="col-lg-12">
		        <div class="panel">
		            <div class="panel-heading">
		                <h3 class="panel-title" style="text-align: right;">
		                	#@installPJaxGoBackBtn()
		                	添加新菜单
		                </h3>
		            </div>
		            <form id="editForm" class="panel-body form-horizontal form-padding">
		            	<div class="form-group">
		                    <label class="col-md-3 control-label">父级菜单</label>
		                    <div class="col-md-5">
		                        <div class="input-group mar-btm">
			                        <input type="text" id="pName" value="#(p?p.name:'根目录')" readonly class="form-control">
									<input type="hidden" id ="pId" name="sysMenu.parent_id"  value="#(p?p.id:'root')">
									<input type="hidden" id = "menuId" name="sysMenu.id" value="#(m?m.id:'')">
			                        
			                        <span class="input-group-btn">
			                            <button class="btn btn-primary" type="button" onclick="selectOneMenu()">选择</button>
			                        </span>
			                    </div>
		                        <small class="help-block">请选择</small>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-3 control-label">名称</label>
		                    <div class="col-md-9">
		                        <input type="text"  name="sysMenu.name" class="form-control"  value="#(m?m.name:'')">
		                        <small class="help-block">请输入名称</small>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-3 control-label">访问地址</label>
		                    <div class="col-md-9">
		                        <input type="text"  name="sysMenu.url" class="form-control"  value="#(m?m.url:'')">
		                        <small class="help-block">请输入访问地址</small>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-3 control-label">描述信息</label>
		                    <div class="col-md-9">
		                        <textarea name="sysMenu.description" rows="9" class="form-control">#(m?m.description:'')</textarea>
		                        <small class="help-block">请输入机构的描述信息</small>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-3 control-label">是否显示</label>
		                    <div class="col-md-4" style="line-height: 30px;">
					            <input  type="checkbox" id="menuIfShow" name="sysMenu.if_show"  value="1" #if(m&&m.if_show=='1') checked #end >
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-3 control-label">显示顺序</label>
		                    <div class="col-md-4">
		                        <input type="text" name="sysMenu.sort" class="form-control" value="#(m?m.sort:'')">
		                        <small class="help-block">请输入机构显示顺序</small>
		                    </div>
		                </div>
		                <div class="panel-footer">
		                    <div class="row">
		                        <div class="col-sm-9 col-sm-offset-3">
		                            <button class="btn btn-warning" type="reset">重置</button>
		                            <button class="btn btn-primary" type="submit" >保存</button>
		                        </div>
		                    </div>
		                </div>
		            </form>
		        </div>
		    </div>
	</div>
	<script>
		function save(){
			var data = common_ajax.ajaxFunc("/admin/sys/menu/save", $('#editForm').serialize(), "json", null);
			if(data.success){
				pointLion.alertMsg("保存成功!" , "success" , "small" , function(){
					location.href = ctx+'/admin/sys/menu/getListPage';//跳转到列表页
				});
			}
		}
		//选择一个父级菜单
		var selectedNode={};
		function selectOneMenu(){
			layer.open({
				  type: 2,
				  title: false, //不显示标题栏
				  area: ['370px', '550px'],
				  shade: 0.2,
				  id: 'selectOneMenu', //设定一个id，防止重复弹出
				  resize: false,
				  closeBtn: false,
				  isOutAnim : false , 
				  btn: ['确定', '取消'], 
				  btnAlign: 'c',
				  content: ctx+'/admin/sys/menu/getSelectOneMenuPage',
				  success: function(layero){
					  
				  },
				  yes: function(){
					  	var thisId = $("#menuId").val();//主键
						if(thisId==selectedNode.id){
							 layer.closeAll();
							 pointLion.alertMsg("您不能选择自己为父级节点!" , "warning" , "small" , null);
							 return;
						}
						$("#pName").val(selectedNode.name);//所选单位名称
						$("#pId").val(selectedNode.id);//所选单位id
					  	layer.closeAll();
				  }
				});
		}
		function setOneMenuNode(node){
			selectedNode = node;
		}
		
		
		$(document).ready(function() {
			new Switchery(document.getElementById('menuIfShow'));//制做开关按钮
		    $('#editForm').bootstrapValidator({
		            fields: {
		            	"sysMenu.name": {
		                    validators: {
		                        notEmpty: {
		                            message: '*菜单名称不能为空'
		                        },
		                        stringLength: {/*长度提示*/
		                            max: 50,
		                            message: '*菜单名称长度必须小于50'
		                        }
		                    }
		                },
		                "sysMenu.sort": {
		                    validators: {
		                    	lessThan: {
		        					inclusive:true,
		        					value: 99,
		        					message: '*请输入小于99的数字'
		        				}
		                    }
		                },
		                "sysMenu.url": {
		                    validators: {
		                    	stringLength: {
		                            max: 100,
		                            message: '*访问地址长度小于100'
		                        }
		                    }
		                },
		                "sysMenu.url": {
		                    validators: {
		                    	stringLength: {
		                            max: 100,
		                            message: '*访问地址长度小于100'
		                        }
		                    }
		                },
		                "sysMenu.permission": {
		                    validators: {
		                    	stringLength: {
		                            max: 50,
		                            message: '*权限标识长度须小于50'
		                        }
		                    }
		                }
		            }
		        }).on("success.form.bv", function (e) {
		            save();
		            return false;//阻止表单跳转
		        });
		});
	</script>